home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX504A / ERROR.BAK < prev    next >
Encoding:
Text File  |  2001-02-09  |  2.0 KB  |  93 lines

  1. /*
  2.  *    ERROR.C
  3.  *
  4.  *    26-May-1988    ml.    Started this.
  5.  *  14-Mar-1989 jye. add codes so that can differ what kind 
  6.  *                     driver currently deal with.
  7.  *
  8.  */
  9.  
  10. #include "osbind.h"
  11. #include "obdefs.h" 
  12. #include "mydefs.h"
  13. #include "addr.h"
  14. #include "myerror.h"
  15.  
  16. extern int typedev;
  17. extern int typedrv;
  18.  
  19. /*
  20.  *  Errcode()
  21.  *    Find error code for previous instruction which returned Check
  22.  *  Condition Status.
  23.  *
  24.  *  Input:
  25.  *    pdev - the physical device number (0 -> 7).
  26.  *  Return:
  27.  *    errnum - the error code.
  28.  */
  29. errcode(pdev)
  30. int pdev;
  31. {
  32.     char data[128];
  33.     extern long rqsense(), ostack;
  34.     UWORD errnum;
  35.     int mask = 0x0001;
  36.     int set, scsidrv;
  37.    
  38.     if (pdev > 15) return ERROR;
  39.     ostack = Super(NULL);
  40.     /* check #pdev device is set or not */
  41.     set = typedev & (mask << pdev);
  42.     scsidrv = typedrv & (mask << pdev);
  43.     if ((set)||(scsidrv)) {    /* if set, it is a removable driver */
  44.         errnum = rqsense(pdev, 16, data);
  45.     } else {    /* if not set, it is a not removable driver */
  46.            errnum = rqsense(pdev, 4, data);
  47.     }
  48.     delay();
  49.     Super(ostack);
  50.     
  51.     if (errnum != 0)
  52.         return err("[1][Fatal error][OK]");
  53.         
  54.     if ((set)||(scsidrv))    { /* if set, it is a removable driver */
  55.         errnum = (UWORD)data[12];
  56.     } else { /* if not set, it is a not removable driver */
  57.         data[0] &= 0x7f;        /* mask out advalid bit */
  58.         errnum = (UWORD)data[0];
  59.     }
  60.     return errnum;        /* return it */
  61. }
  62.  
  63.  
  64. /*
  65.  *  Tsterr()
  66.  *    Given an error code, test if it is a medium change error
  67.  *  or a write protection error.  Put up the appropiate box if
  68.  *  it is either one of those, and return OK.  
  69.  *    If it is not either of those, return ERROR.
  70.  *
  71.  */
  72. tsterr(errnum)
  73. UWORD errnum;
  74. {
  75.     switch(errnum) {
  76.         case MDMCHGD:
  77.             err(mdmchng);
  78.             break;
  79.         
  80.         case WRTPRTD:
  81.             err(wrprotct);
  82.             break;
  83.             
  84.         case DEVNRDY:
  85.             err(drvnrdy);
  86.             break;
  87.             
  88.         default:
  89.             return ERROR;
  90.     }
  91.     return OK;
  92. }
  93.